/******************************************************************************\
*  Animeshell 1.0 Multimedia manager                                           *
*  Copyright (C) 2006-2007 Rémy Guillemette <shaikadzari@gmail.com>            *
*                                                                              *
*  This program is free software; you can redistribute it and/or modify        *
*  it under the terms of the GNU General Public License version 2 only as      *
*  published by the Free Software Foundation.                                  *
*                                                                              *
*  This program is distributed in the hope that it will be useful,             *
*  but WITHOUT ANY WARRANTY; without even the implied warranty of              *
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
*  GNU General Public License for more details.                                *
*                                                                              *
*  You should have received a copy of the GNU General Public License           *
*  along with this program; if not, write to the                               *
*  Free Software Foundation, Inc.,                                             *
*  59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                   *
\******************************************************************************/

#include <QApplication>
#include <QSplashScreen>
#include <QPixmap>
#include <QBitmap>
#include <QThread>
#include <QTranslator>
#include <QString>
#include <QTextCodec>

#include "frmAnimeshellimpl.h"

//
int main(int argc, char ** argv)
{
	Q_INIT_RESOURCE(res);
	QString locale = QLocale::system().name();
	
	QApplication app( argc, argv );
	
	// Language
	QTranslator translator( 0 );
    if ( !translator.load( QString(":/lang/resources/AShell_") + locale) )
    	translator.load( QString(":/lang/resources/AShell_fr") );
    
    app.installTranslator( &translator );
	
	QPixmap pixmap(":/banniere/resources/splash.png");
	QSplashScreen * splash = new QSplashScreen(pixmap);
	
	Qt::Alignment topRight = Qt::AlignCenter | Qt::AlignBottom;
	splash->setMask(pixmap.mask());
	splash->show();
	
	MainWindowImpl win;
	splash->showMessage(QObject::tr("Chargement initial"),topRight,Qt::black);
	if ( win.initialload() )
	{
		splash->showMessage(QObject::tr("Chargement de la base de données d'Animeshell..."),topRight,Qt::black);
		if ( win.initialdatabase() )
		{
			splash->showMessage(QObject::tr("Chargement de la fenêtre principal..."),topRight,Qt::black);
			splash->finish(&win);
			
			win.show(); 
			app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
			return app.exec();
		}
		
	}
	return 1;
}
//
